using JGSY.CMS.LowCode.Platform.Application.DTOs;
using System.Threading.Tasks;

namespace JGSY.CMS.LowCode.Platform.Application.Interfaces
{
    /// <summary>
    /// 身份认证应用服务接口。
    /// 提供用户注册、登录、令牌刷新、短信验证、密码重置等身份认证相关业务功能接口定义。
    /// </summary>
    public interface IAuthenticationAppService
    {
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="email">邮箱地址</param>
        /// <param name="password">密码</param>
        /// <param name="phone">手机号，可选</param>
        /// <returns>注册任务</returns>
        Task RegisterAsync(string username, string email, string password, string? phone = null);
        
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>访问令牌</returns>
        Task<string> LoginAsync(string username, string password);
        
        /// <summary>
        /// 刷新访问令牌
        /// </summary>
        /// <param name="refreshToken">刷新令牌</param>
        /// <returns>新的访问令牌</returns>
        Task<string> RefreshTokenAsync(string refreshToken);
        
        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <returns>发送任务</returns>
        Task SendSmsCodeAsync(string phone);
        
        /// <summary>
        /// 验证短信验证码
        /// </summary>
        /// <param name="phone">手机号</param>
        /// <param name="code">验证码</param>
        /// <returns>验证结果</returns>
        Task<bool> VerifySmsCodeAsync(string phone, string code);
        
        /// <summary>
        /// 请求密码重置
        /// </summary>
        /// <param name="email">邮箱地址</param>
        /// <returns>请求任务</returns>
        Task RequestPasswordResetAsync(string email);
        
        /// <summary>
        /// 确认密码重置
        /// </summary>
        /// <param name="email">邮箱地址</param>
        /// <param name="code">重置验证码</param>
        /// <param name="newPassword">新密码</param>
        /// <returns>重置结果</returns>
        Task<bool> ConfirmPasswordResetAsync(string email, string code, string newPassword);
        
        /// <summary>
        /// 获取当前用户信息
        /// </summary>
        /// <returns>用户信息</returns>
        Task<UserDto?> GetCurrentUserAsync();
        
        /// <summary>
        /// 用户登出
        /// </summary>
        /// <returns>登出任务</returns>
        Task LogoutAsync();
    }
}
